<template>
  <!--供应商信息-施工班组列表-->
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <a-col :md="6" :sm="12">
            <a-form-item label="名称">
              <!--<a-input placeholder="请输入账号查询" v-model="queryParam.username"></a-input>-->
              <j-input placeholder="输入名称模糊查询" v-model="queryParam.name"></j-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="12">
            <a-form-item label="施工范围">
              <!--<a-input placeholder="请输入账号查询" v-model="queryParam.username"></a-input>-->
              <j-input placeholder="输入施工范围模糊查询" v-model="queryParam.mainProduct"></j-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="12">
            <a-form-item label="班组分类">
              <!--<a-input placeholder="请输入账号查询" v-model="queryParam.username"></a-input>-->
              <j-input placeholder="输入班组分类模糊查询" v-model="queryParam.construction_team"></j-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" style="background-color:#32cd99;color: white;" icon="plus">新增施工班组</a-button>
      <!-- <a-button type="primary" icon="download" @click="handleExportXls('供应商')">导出</a-button> -->
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
        @change="handleImportExcel">
        <!-- <a-button type="primary" icon="import">导入</a-button> -->
      </a-upload>
      <!-- 高级查询区域 -->
    </div>
    <!-- table区域-begin -->
    <a-table ref="table" size="middle" :scroll="{x:true}" bordered rowKey="id" :columns="columns"
      :dataSource="dataSource" :pagination="ipagination" :loading="loading" class="j-table-force-nowrap"
      @change="handleTableChange">

      <template slot="htmlSlot" slot-scope="text">
        <div v-html="text"></div>
      </template>
      <template slot="imgSlot" slot-scope="text,record">
        <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
        <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt=""
          style="max-width:80px;font-size: 12px;font-style: italic;" />
      </template>
      <template slot="fileSlot" slot-scope="text">
        <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
        <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
          下载
        </a-button>
      </template>
      <template slot="action" slot-scope="text, record">
        <a @click="handleEdit(record)">编辑</a>
        <a-divider type="vertical" />
        <a @click="handleDetail(record)">详情</a>
        <a-divider type="vertical" />
        <a @click="handleScore(record,'teamedit')">修改评分</a>
        <a-divider type="vertical" />
        <a @click="handleScore(record,'teamdetail')">评分记录</a>
        <a-divider type="vertical" />
        <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
          <a>删除</a>
        </a-popconfirm>
      </template>
    </a-table>
    </div>
    <wt-team-modal ref="modalForm" @ok="modalFormOk"></wt-team-modal>
    <score-modal ref="modalForm2" @ok="modalFormOk"></score-modal>
  </a-card>
</template>

<script>
  import '@/assets/less/TableExpand.less'
  import {
    mixinDevice
  } from '@/utils/mixin'
  import {
    JeecgListMixin
  } from '@/mixins/JeecgListMixin'
  import WtTeamModal from './modules/WtTeamModal'
  import ScoreModal from './components/ScoreModal.vue'
  export default {
    name: 'WtTeamList',
    mixins: [JeecgListMixin, mixinDevice],
    components: {
      WtTeamModal,ScoreModal
    },
    data() {
      return {
        description: '时光页面',
        // 表头
        columns: [
          {
            title: '名称',
            align: "center",
            dataIndex: 'name',
            width: 120
          },

          {
            title: '联系人',
            align: "center",
            dataIndex: 'relation'
          },
          {
            title: '电话',
            align: "center",
            dataIndex: 'phone'
          },
          {
            title: '班组分类',
            align: "center",
            dataIndex: 'construction_team'
          },
          {
            title: '施工范围',
            align: "center",
            dataIndex: 'mainProduct'
          },
          {
            title: '地址',
            align: "center",
            dataIndex: 'address'
          },
          {
          	title: '采购商综合打分（按月更新）',
          	align: 'center',
          	width:100,
          	dataIndex: 'buyerScore',
          },
          {
          	title: '参与打分采购商数',
          	align: 'center',
          	width:100,
          	dataIndex: 'buyerNum',
          },
          {
          	title: '基础评分',
          	align: 'center',
          	dataIndex: 'score',
          },
          {
          	title: '运维最新评分',
          	align: 'center',
          	dataIndex: 'operationScore',
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: "center",
            fixed: "right",
            width: 147,
            scopedSlots: {
              customRender: 'action'
            }
          }
        ],
        url: {
          list: "/wtSupplier/list",
          delete: "/wtSupplier/delete",
          deleteBatch: "/wtSupplier/deleteBatch",
          exportXlsUrl: "/wtSupplier/exportXls",
          importExcelUrl: "/wtSupplier/importExcel",
        },
        dictOptions: {},
        superFieldList: [],
        queryParam: {
          type: '1',
					scoreType:'1'
        },
      }
    },
    created() {
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function() {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      handleScore(record,type){
        if(type === 'teamedit'){
          this.$refs.modalForm2.title = '修改评分';
          this.$refs.modalForm2.disableSubmit = false;
        }else if(type === 'teamdetail'){
          this.$refs.modalForm2.title = '评分记录';
          this.$refs.modalForm2.disableSubmit = true;
        }
        this.$refs.modalForm2.pageType = type;
        this.$refs.modalForm2.edit(record);
      },
      initDictConfig() {},
      getSuperFieldList() {
        let fieldList = [];
        fieldList.push({
          type: 'string',
          value: 'name',
          text: '名称',
          dictCode: ''
        })
        fieldList.push({
          type: 'int',
          value: 'type',
          text: '0经营产品1施工',
          dictCode: ''
        })
        fieldList.push({
          type: 'string',
          value: 'relation',
          text: '联系人',
          dictCode: ''
        })
        fieldList.push({
          type: 'string',
          value: 'phone',
          text: '电话',
          dictCode: ''
        })
        fieldList.push({
          type: 'string',
          value: 'address',
          text: '地址',
          dictCode: ''
        })
        fieldList.push({
          type: 'string',
          value: 'score',
          text: '评分',
          dictCode: ''
        })
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>